<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class ModifyMessageTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('messages', function (Blueprint $blueprint) {
            $blueprint->dropIndex('messages_from_index');
            $blueprint->dropIndex('messages_to_index');
            $blueprint->dropIndex('messages_to_type_index');

            $blueprint->dropColumn('from');
            $blueprint->dropColumn('from_type');
            $blueprint->dropColumn('to');
            $blueprint->dropColumn('to_type');

            $blueprint->integer('member_id')->unsigned()->comment('接收消息的用户 ID')->index();
            $blueprint->boolean('status')->default(false)->comment('是否已读');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        //
    }
}
